package 实验9;
import java.util.Scanner;
public class 计算未来投资值 {
	public static void main(String[] args){
		double inv ,ann ;
		int years;
		Scanner s = new Scanner(System.in);
		System.out.print("请输入投资金额：");
		inv = s.nextDouble();
		System.out.print("请输入年利率（%）");
		ann = s.nextDouble();
		System.out.print("请输入投资年数：");
		years = s.nextInt();
		s.close();
		计算  v = new 计算(inv, ann,years);
		System.out.printf("未来投资额为：$%.2f", v.getVal());
	}
}
class 计算 {
	private double val;
	public 计算 (double inv ,double ann ,int years) throws IllegalArgumentException{
		if(inv <= 0 || ann <= 0 || years <= 0) throw new IllegalArgumentException();
		val = inv * Math.pow((1 + ann / 100D),years);
	}

	public double getVal() {
		return val;
	}
}